package com.fcscs.cservice.client.main.configuration.inroomdining;

import com.extjs.gxt.ui.client.event.ButtonEvent;
import com.extjs.gxt.ui.client.event.SelectionListener;
import com.extjs.gxt.ui.client.store.ListStore;
import com.extjs.gxt.ui.client.widget.HorizontalPanel;
import com.extjs.gxt.ui.client.widget.Label;
import com.extjs.gxt.ui.client.widget.LayoutContainer;
import com.extjs.gxt.ui.client.widget.VerticalPanel;
import com.extjs.gxt.ui.client.widget.form.CheckBox;
import com.extjs.gxt.ui.client.widget.form.ComboBox.TriggerAction;
import com.extjs.gxt.ui.client.widget.form.TextField;
import com.extjs.gxt.ui.client.widget.layout.ColumnData;
import com.extjs.gxt.ui.client.widget.layout.ColumnLayout;
import com.fcscs.core.gwt.common.CoreConstants;
import com.fcscs.core.gwt.common.FormSubmitListener;
import com.fcscs.core.gwt.common.ui.BaseFormDialog;
import com.fcscs.core.gwt.common.ui.FcsFields.EasyClearCombobox;
import com.fcscs.core.gwt.common.ui.FcsFields.FormButton;
import com.fcscs.core.gwt.common.ui.FcsFormPanel;
import com.fcscs.cservice.client.common.CServiceConstants;
import com.fcscs.cservice.client.common.model.configuration.inroomdining.ChargeCategory;
import com.fcscs.cservice.client.common.model.configuration.inroomdining.ChargeCategoryModelData;
import com.fcscs.cservice.client.common.model.configuration.reservation.PropertyIdNameModelData;

public class ChargeCategoryCommonConfigDialog extends BaseFormDialog<PropertyIdNameModelData> {

	private static ChargeCategoryCommonConfigDialog INSTANCE;
	private MyFormPanel myFormPanel;
	private HorizontalPanel hp1;
	private LayoutContainer lc1;
//	private TextField<String> nameField;
	private HorizontalPanel hp2;
	private LayoutContainer lc2;
	private HorizontalPanel hp3;
	private LayoutContainer lc3;
	private ListStore<ChargeCategoryModelData> revenueStore;
	private FormButton saveBtn;
	private FormButton cancelBtn;
	private CheckBox deliveryBox;
	private EasyClearCombobox<ChargeCategoryModelData> decimalPlaCombox;
	private EasyClearCombobox<ChargeCategoryModelData> roundingCombox;
	private EasyClearCombobox<ChargeCategoryModelData> chargeByCombox;
	private TextField<String> codeField;
	private TextField<String> valueField;
	private EasyClearCombobox<ChargeCategoryModelData> txTypeCombox;

	private HorizontalPanel hp4;
	private LayoutContainer lc4;

	public static ChargeCategoryCommonConfigDialog getInstance() {

		if (null == INSTANCE) {
			INSTANCE = new ChargeCategoryCommonConfigDialog();
		}
		// INSTANCE.newSearch();
		INSTANCE.setHeading(CoreConstants.CORE_MESSAGES.operation(CoreConstants.CORE_CONSTANTS.add(),
				CServiceConstants.CSERVICE_CONSTANTS.setCommonConfig()));
		return INSTANCE;
	}

	private ChargeCategoryCommonConfigDialog() {
		myFormPanel = new MyFormPanel(null);
		add(myFormPanel);
		setSize(650, 230);
	}

	public class MyFormPanel extends FcsFormPanel<ChargeCategory> {

		protected MyFormPanel(FormSubmitListener<ChargeCategory> l) {
			super(l);
			setHeaderVisible(false);

			VerticalPanel vp = new VerticalPanel();
			vp.setSpacing(5);
			vp.setId("ChargeCategoryCommonConfigDialog_vp");

			hp1 = new HorizontalPanel();
			hp1.setId("ChargeCategoryCommonConfigDialog_hp1");
			vp.add(hp1);

			lc1 = new LayoutContainer();
			lc1.setId("ChargeCategoryCommonConfigDialog_lc1");
			lc1.setLayout(new ColumnLayout());
			hp1.add(lc1);

//			Label nameLabel = new Label(CServiceConstants.CSERVICE_CONSTANTS.rename() + CServiceConstants.FIELD_SEP);
//			nameLabel.setId("ChargeCategoryCommonConfigDialog_nameLabel");
//			lc1.add(nameLabel, new ColumnData(100));
//
//			nameField = new TextField<String>();
//			nameField.setId("ChargeCategoryCommonConfigDialog_nameField");
//			lc1.add(nameField, new ColumnData(150));

			deliveryBox = new CheckBox();
			deliveryBox.setStyleAttribute(CServiceConstants.CSS_MARGINLEFT, "180px");
			deliveryBox.setId("ChargeCategoryCommonConfigDialog_deliveryBox");
			deliveryBox.setBoxLabel(CServiceConstants.CSERVICE_CONSTANTS.deliveryCharge());
			lc1.add(deliveryBox, new ColumnData(150));

			hp2 = new HorizontalPanel();
			hp2.setId("ChargeCategoryCommonConfigDialog_hp2");
			vp.add(hp2);

			lc2 = new LayoutContainer();
			lc2.setId("ChargeCategoryCommonConfigDialog_lc2");
			lc2.setLayout(new ColumnLayout());
			hp2.add(lc2);

			Label decimalPlacesLabel = new Label(CServiceConstants.CSERVICE_CONSTANTS.decimalPlaces()
					+ CServiceConstants.FIELD_SEP);
			decimalPlacesLabel.setId("ChargeCategoryCommonConfigDialog_decimalPlacesLabel");
			lc2.add(decimalPlacesLabel, new ColumnData(100));

			decimalPlaCombox = new EasyClearCombobox<ChargeCategoryModelData>();
			decimalPlaCombox.setId("ChargeCategoryCommonConfigDialog_revenueCombox");
			revenueStore = new ListStore<ChargeCategoryModelData>();
			decimalPlaCombox.setStore(revenueStore);
			decimalPlaCombox.setDisplayField(CoreConstants.FULLTNAME);
			decimalPlaCombox.setTriggerAction(TriggerAction.ALL);
			decimalPlaCombox.setForceSelection(true);
			lc2.add(decimalPlaCombox, new ColumnData(150));

			Label roundingLabel = new Label(CServiceConstants.CSERVICE_CONSTANTS.rounding() + CServiceConstants.FIELD_SEP);
			roundingLabel.setStyleAttribute(CServiceConstants.CSS_MARGINLEFT, "80px");
			roundingLabel.setId("ChargeCategoryCommonConfigDialog_decimalPlacesLabel");
			lc2.add(roundingLabel, new ColumnData(100));

			roundingCombox = new EasyClearCombobox<ChargeCategoryModelData>();
			roundingCombox.setId("ChargeCategoryCommonConfigDialog_roundingCombox");
			revenueStore = new ListStore<ChargeCategoryModelData>();
			roundingCombox.setStore(revenueStore);
			roundingCombox.setDisplayField(CoreConstants.FULLTNAME);
			roundingCombox.setTriggerAction(TriggerAction.ALL);
			roundingCombox.setForceSelection(true);
			lc2.add(roundingCombox, new ColumnData(150));

			hp3 = new HorizontalPanel();
			hp3.setId("ChargeCategoryCommonConfigDialog_hp3");
			vp.add(hp3);

			lc3 = new LayoutContainer();
			lc3.setId("ChargeCategoryCommonConfigDialog_lc3");
			lc3.setLayout(new ColumnLayout());
			hp3.add(lc3);

			Label revenueLabel = new Label(CServiceConstants.CSERVICE_CONSTANTS.revenue() + CServiceConstants.FIELD_SEP);
			revenueLabel.setId("ChargeCategoryCommonConfigDialog_revenueLabel");
			lc3.add(revenueLabel, new ColumnData(100));

			chargeByCombox = new EasyClearCombobox<ChargeCategoryModelData>();
			chargeByCombox.setId("ChargeCategoryCommonConfigDialog_chargeByCombox");
			revenueStore = new ListStore<ChargeCategoryModelData>();
			chargeByCombox.setStore(revenueStore);
			chargeByCombox.setDisplayField(CoreConstants.FULLTNAME);
			chargeByCombox.setTriggerAction(TriggerAction.ALL);
			chargeByCombox.setForceSelection(true);
			lc3.add(chargeByCombox, new ColumnData(150));

			Label valueLabel = new Label(CServiceConstants.CSERVICE_CONSTANTS.value() + CServiceConstants.FIELD_SEP);
			valueLabel.setStyleAttribute(CServiceConstants.CSS_MARGINLEFT, "80px");
			valueLabel.setId("ChargeCategoryCommonConfigDialog_valueLabel");
			lc3.add(valueLabel, new ColumnData(100));

			valueField = new TextField<String>();
			valueField.setId("ChargeCategoryCommonConfigDialog_valueField");
			lc3.add(valueField, new ColumnData(150));

			hp4 = new HorizontalPanel();
			hp4.setId("ChargeCategoryCommonConfigDialog_hp1");
			vp.add(hp4);

			lc4 = new LayoutContainer();
			lc4.setId("ChargeCategoryCommonConfigDialog_lc4");
			lc4.setLayout(new ColumnLayout());
			hp4.add(lc4);

			Label codeLabel = new Label(CoreConstants.CORE_CONSTANTS.code() + CServiceConstants.FIELD_SEP);
			codeLabel.setId("ChargeCategoryCommonConfigDialog_codeLabel");
			lc4.add(codeLabel, new ColumnData(100));

			codeField = new TextField<String>();
			codeField.setId("ChargeCategoryCommonConfigDialog_nameField");
			lc4.add(codeField, new ColumnData(150));

			Label typeLabel = new Label(CServiceConstants.CSERVICE_CONSTANTS.transactionType() + CServiceConstants.FIELD_SEP);
			typeLabel.setStyleAttribute(CServiceConstants.CSS_MARGINLEFT, "80px");
			typeLabel.setId("ChargeCategoryCommonConfigDialog_typeLabel");
			lc4.add(typeLabel, new ColumnData(100));

			txTypeCombox = new EasyClearCombobox<ChargeCategoryModelData>();
			txTypeCombox.setId("ChargeCategoryCommonConfigDialog_txTypeCombox");
			revenueStore = new ListStore<ChargeCategoryModelData>();
			txTypeCombox.setStore(revenueStore);
			txTypeCombox.setDisplayField(CoreConstants.FULLTNAME);
			txTypeCombox.setTriggerAction(TriggerAction.ALL);
			txTypeCombox.setForceSelection(true);
			lc4.add(txTypeCombox, new ColumnData(150));

			saveBtn = new FormButton(CoreConstants.CORE_CONSTANTS.save());
			saveBtn.setId("ChargeCategoryCommonConfigDialog_saveBtn_Id");
			getButtonBar().add(saveBtn);

			cancelBtn = new FormButton(CoreConstants.CORE_CONSTANTS.cancel());
			cancelBtn.setId("ChargeCategoryCommonConfigDialog_cancelBtn_Id");
			cancelBtn.addSelectionListener(new SelectionListener<ButtonEvent>() {

				@Override
				public void componentSelected(ButtonEvent ce) {
					ChargeCategoryCommonConfigDialog.this.hide();
					cancelBtn.removeStyleName(CoreConstants.CSS_FORM_BUTTON_FOCUS);
				}
			});
			getButtonBar().add(cancelBtn);

			add(vp);

		}

		@Override
		public void setFocus() {

		}

		@Override
		public void updateForm(ChargeCategory entity) {
			// TODO Auto-generated method stub

		}

		@Override
		public void populateEntity(ChargeCategory entity) {
			// TODO Auto-generated method stub

		}

	}

	@Override
	protected FcsFormPanel<PropertyIdNameModelData> getFormPanel() {
		// TODO Auto-generated method stub
		return null;
	}

}
